package asteroids.model.programs.expressions.BasicExpressions;

import asteroids.model.programs.expressions.BasicExpression;
import asteroids.model.programs.statements.Statement;
import asteroids.model.programs.types.Type;

public class Self extends BasicExpression {

	public Self(int line, int column) {
		super(line, column);
	}
	
	/**
	 * returns this Basic Expression
	 */
	@Override
	public BasicExpression getResult() {
		return thisShip;
	}
	
	/**
	 * Should return the ship it references
	 * @return thisShip
	 */
	public Entity getValue(){
		return thisShip;
	}
		
	/**
	 * @return the textual form of this basic expression
	 * 			| return "self"
	 */
	@Override
	public String toString() {
		return "self";
	}
	
	public void setStatement(Statement newStatement){
		super.setStatement(newStatement);
		thisShip = new Entity(this.getStatement().getProgram().getSelf(), 0, 0);
	}
	
	private Entity thisShip;
	
	@Override
	public Type getType(){
		return Type.ENTITY;
	}

}
